import request from '@/utils/request'
import BaseUrl from '@/utils/BaseUrl'
import { getRealname } from '@/utils/auth'

export function listSysUser(query) {
  return request({
    url: BaseUrl.API_SYS + '/sys/user/list',
    method: 'post',
    data: query
  })
}

/**
 * 删除角色
 * @param data
 * @returns {AxiosPromise}
 */
export function deleteSysUser(data) {
  return request({
    url: BaseUrl.API_SYS + '/sys/user/delete',
    method: 'post',
    data: data
  })
}

/**
 * 增加角色
 * @param data
 * @returns {AxiosPromise}
 */
export function addSysUser(data) {
  data.createdBy = getRealname()
  return request({
    url: BaseUrl.API_SYS + '/sys/user/add',
    data: data
  })
}

/**
 * 修改角色
 * @param data
 * @returns {AxiosPromise}
 */
export function updateSysUser(data) {
  data.modifiedBy = getRealname()
  return request({
    url: BaseUrl.API_SYS + '/sys/user/update',
    data: data
  })
}

/**
 * 获取单个角色
 * @param query
 * @returns {AxiosPromise}
 */
export function getSysUser(query) {
  return request({
    url: BaseUrl.API_SYS + '/sys/user/get',
    method: 'post',
    data: query
  })
}
